<?php
namespace UserApi\Controller;
use Zend\Mvc\Controller\AbstractRestfulController;
use Zend\View\Model\JsonModel;
class ChangepasswordApiController extends AbstractRestfulController
{
    public function getList()
    {			
			
    }
    public function get($user_id)
    {			
		
    }
    public function create($data)
    {
		
    }
    public function update($uid, $passwords)
    {
		header('Access-Control-Allow-Origin: *');	
		$userTable=$this->getServiceLocator()->get('Models\Model\UserFactory');
		if(!empty($passwords)){
			$check_old_password = $userTable->getpassword($uid,$passwords['old_password']);
			if($check_old_password!=0){
				$change_password = $userTable->changepwd($uid,$passwords['cnf_password']);
				if($change_password>=0){
					return new JsonModel(array(
						'output' => 'success',
					));
				}else{
					return new JsonModel(array(
						'output' => 'fail',
					));
				}
			}else{
				return new JsonModel(array(
					'output' => 'fail',
				));	
			}
		}
    }
    public function delete($id)
    {
       
    }
}